package cn.jsj.dispose;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * 修改个人联系方式处理类
 * @author LI
 *
 */
 public class ModifyPersonalContact extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

	  //调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("进入修改联系方式处理类！！！");

		 //用户id,角色编号，新的联系方式
		 int userId=Integer.parseInt(request.getParameter("userId"));
		 int role=Integer.parseInt(request.getParameter("role"));
		 String contactWay=request.getParameter("new_contact");

		 //调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("  "+userId+"   "+role+"    "+contactWay);

		//输出对象
		 java.io.PrintWriter out=response.getWriter();

		//修改结果 1.成功 0 失败
		 int modifyResult;
		 //role:1. 律师 2.实习律师 3.行政人员 4.律师助理
		 if(role==1){
			 cn.jsj.dao.TblLawyerDAO tld=new cn.jsj.dao.TblLawyerDAO();
			modifyResult= tld.modifyContactWay(contactWay, userId);

			//调试信息
			cn.jsj.utils.SysLogger.PrintInfo("修改结果-------->"+modifyResult);

			//判断修改结果
			if(modifyResult==1){
				out.println("{message:'修改成功'}");
				out.flush();
				 return;
			}
			else{
				out.println("{message:'修改失败！'}");
				out.flush();
				 return;
			}
		 }

		 //如果为行政人员
		 if(role==3){
			 cn.jsj.dao.TblAdminPersonnelDAO tapd=new cn.jsj.dao.TblAdminPersonnelDAO();
			 modifyResult=tapd.modifyContactWay(contactWay, userId);
			//调试信息
				cn.jsj.utils.SysLogger.PrintInfo("修改结果3-------->"+modifyResult);

			//判断修改结果
				if(modifyResult==1){
					out.println("{message:'修改成功'}");
					out.flush();
					 return;
				}
				else{
					out.println("{message:'修改失败！'}");
					out.flush();
					 return;
				}
		 }



	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}
}